package com.pattern.structural.adaptor.class2;

/**
 * @Description Client role
 * @Author Ping
 * @Date 2022/3/29 14:19
 **/
public class Computer {
    private  EUsedElectricity eUsedElectricity ;

    public Computer(EUsedElectricity eUsedElectricity) {
        this.eUsedElectricity = eUsedElectricity;
    }

    public void seteUsedElectricity(EUsedElectricity eUsedElectricity) {
        this.eUsedElectricity = eUsedElectricity;
    }

    public void doCharging() {
        System.out.println("Computer run out of power .");
        this.eUsedElectricity.chargeWith22V();
        System.out.println("Computer got power again ! ") ;
    }

    public static void main(String args[]) {
        // adpting by class type adapter .
//         Computer computer = new Computer(new ObjAdapter()) ;
//         computer.doCharging();
         // adpting by object tpye adapter

        HomeUsedElectricity homeUsedElectricity = new HomeUsedElectricity() ;
        Computer computer = new Computer(new ObjAdapter(homeUsedElectricity)) ;
        computer.doCharging();

    }
}
